<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('字典数据列表')" />
	<th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<!--<th:p th:text="'dict='+${dict}">哈哈哈</th:p>-->
		<!--<th:p th:text="'dictList'+${dictList}">哈哈哈</th:p>-->
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="data-form">
					<div class="select-list">
						<ul>
						    <li>
								参数组名称：
								<select id="paramsGroupId" name="paramsGroupId" class="form-control">
					                <option th:each="dictItem : ${dictList}" th:text="${dictItem['paramsGroupName']}" th:value="${dictItem['paramsGroupId']}" th:selected="${dictItem['paramsGroupId'] == dict['paramsGroupId']}"></option>
								</select>
							</li>
							<li>
								参数键：<input type="text" name="paramsKey"/>
							</li>
							<li>
								参数值：<input type="text" name="paramsValue"/>
							</li>
							<li>
								是否加密：<select name="encrypt" th:with="type=${@dict.getType('ENCRYPT_STATUS')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li>
								数据状态：<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
									      <option value="" >全部</option>
								          <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								      </select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

	       <div class="btn-group-sm" id="toolbar" role="group">
	            <a class="btn btn-success" onclick="add()" shiro:hasPermission="busi:paramsGroup:add">
	                <i class="fa fa-plus"></i> 新增
	            </a>
				<!--<a class="btn btn-danger multiple" onclick="$.operate.removeAll()" shiro:hasPermission="busi:paramsGroup:remove">-->
		            <!--<i class="fa fa-remove"></i> 删除-->
		        <!--</a>-->
		        <a class="btn btn-danger" onclick="closeItem()">
		            <i class="fa fa-reply-all"></i> 关闭
		        </a>
	        </div>

	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>

	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('busi:paramsGroup:edit')}]];
		var removeFlag = [[${@permission.hasPermi('busi:paramsGroup:remove')}]];
		var datas = [[${@dict.getType('sys_normal_disable')}]];
		var encryptStatus = [[${@dict.getType('ENCRYPT_STATUS')}]];
		var prefix = ctx + "watchdog/params";

		$(function() {
			var options = {
				url: prefix + "/list",
				createUrl: prefix + "/add/{id}",
				updateUrl: prefix + "/edit/{id}",
				removeUrl: prefix + "/remove",
				// exportUrl: prefix + "/export",
				queryParams: queryParams,
				sortName: "createdTime",
		        sortOrder: "desc",
				modalName: "数据",
				columns: [{
						checkbox: true
					},
					{
						field: 'paramsId',
						visible: false
					},
					{
						field: 'paramsGroupId',
						visible: false
					},
					{
						field: 'paramsGroupName',
						title: '参数组名称',
						// formatter: function(value, row, index) {
						// 	console.log("value=",value," row=", row, " index=",index)
						// 	var listClass = $.common.equals("default", row.listClass) || $.common.isEmpty(row.listClass) ? "" : "badge badge-" + row.listClass;
						// 	console.log("listClass=",listClass)
	                    // 	return $.common.sprintf("<span class='%s'>%s</span>", listClass, value);
						// }
					},
					{
						field: 'paramsKey',
						title: '参数键'
					},
					{
						field: 'paramsValue',
						title: '参数值'
					},
					{
						field: 'encrypt',
						title: '是否加密',
						align: 'center',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(encryptStatus, value);
						}
					},
					{
						field: 'status',
						title: '状态',
						align: 'center',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(datas, value);
						}
					},
					{
						field: 'createdTime',
						title: '创建时间',
						sortable: true
					},
					{
						field: 'updatedTime',
						title: '更新时间',
						sortable: true
					},
					{
						field: 'remark',
						title: '备注'
					},
					{
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							var actions = [];
							actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.paramsId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
							actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.paramsId + '\')"><i class="fa fa-remove"></i>删除</a>');
							return actions.join('');
						}
					}]
				};
			$.table.init(options);
		});

		function queryParams(params) {
			var search = $.table.queryParams(params);
			search.dictType = $("#paramsGroupId").val();
			return search;
		}

		/*运行参数-新增参数*/
		function add() {
		    var dictType = $("#paramsGroupId option:selected").val();
		    $.operate.add(dictType);
		}

		function resetPre() {
			$.form.reset();
			$("#dictType").val($("#paramsGroupId").val()).trigger("change");
		}
	</script>
<script th:inline="javascript">

</script>
</body>
</html>